package pantallas;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class PantallaFinPartida implements ActionListener ,WindowListener {

/************atributos*******************************************/
    private JFrame ventanaError;
/*****************************************************************/

/************métodos**********************************************/

    public PantallaFinPartida(String mensaje) {
        crearPantalla(mensaje);
        mostrarPantalla();
    }

    public void crearPantalla(String mensaje ){
        ventanaError = new JFrame("Fin");
        ventanaError.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ventanaError.setBounds(100, 100, 400, 300);
        ventanaError.getContentPane().setLayout(null);
        ventanaError.addWindowListener(this);

        JLabel txt0 = new JLabel(mensaje);
        txt0.setBounds(15, 100, 350, 20);
        ventanaError.getContentPane().add(txt0);

        JButton aceptar = new JButton("Salir");
        aceptar.setBounds(80, 230, 100, 20);
        ventanaError.getContentPane().add(aceptar);
        aceptar.setMnemonic(KeyEvent.VK_A);
        aceptar.setActionCommand("salir");
        aceptar.addActionListener(this);
    }
    public void mostrarPantalla(){
        ventanaError.setVisible(true);
    }
    public void ocultarPantalla(){
        ventanaError.setVisible(false);
    }
    public void actionPerformed(ActionEvent e) {
         if ("salir".equals(e.getActionCommand())){
            System.exit(0);
         }
    }

    public void windowOpened(WindowEvent e) { }
    public void windowClosing(WindowEvent e) {
        ventanaError.setVisible(false);
    }
    public void windowClosed(WindowEvent e) {
        ventanaError.setVisible(false);
    }
    public void windowIconified(WindowEvent e) { }
    public void windowDeiconified(WindowEvent e) { }
    public void windowActivated(WindowEvent e) { }
    public void windowDeactivated(WindowEvent e) { }
/*****************************************************************/
    }